package com.boomsecret.classloader;

/**
 * Created by wangjinliang on 2018/1/31.
 */
public class ClassLoaderDemo {
    public static void main(String[] args) {
        CustomAClassLoader classLoader = new CustomAClassLoader();
        String name = "com.boomsecret.classloader.ClassLoaderTest";
        try {
            String filePath = "C:/MineProjects/JavaDemo/target/classes/";
            Class<ClassLoaderTest> testClassOne =
                    (Class<ClassLoaderTest>) classLoader.findClassByFilePathAndName(filePath, name);
            ClassLoaderTest test = testClassOne.newInstance();
            test.say();
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            Class<ClassLoaderTest> testClassOne =
                    (Class<ClassLoaderTest>) ClassLoaderDemo.class.getClassLoader().loadClass(name);
            ClassLoaderTest test = testClassOne.newInstance();
            test.say();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
